package com.javaweb.blogcite.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Toc {
    private String name;
    private String anchor;
    private Integer level;
    private List<Toc> children;

    public Toc(String name, Integer level) {
        this.name = name;
        this.anchor = name;  // anchor 与 name 一致
        this.level = level;
        this.children = new ArrayList<>();
    }

    // 添加子目录
    public void addChild(Toc child) {
        this.children.add(child);
    }
}
